﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace cds_betadev01.source
{
    class Moteur_jeu
    {
        public Moteur_jeu()
        {
            view = new Camera();

        }
        private Camera view;
        private Dictionary<string,int>dico;
        private int Lastindex;
        private List<ObjDisplay> modelArray;
        public void DrawAndUpload()
        {
            view.upload();
            foreach (ObjDisplay i in modelArray)
            {
                i.upload();
                view.draw(i);
            }
                
        }
        public void add(string nom, ObjDisplay obj)
        {
            modelArray.Add(obj);
            Lastindex++;
            dico.Add(nom, Lastindex);
        }
        public ObjDisplay getObj(string name)
        {
            int i = 0;
            if (dico.TryGetValue(name, out i))
                return modelArray.ElementAt(i);
            else throw new Exception("aucun objet avec le nom " + name);
               
        }
        public ObjDisplay getObj(int i)
        {
            return modelArray.ElementAt(i);
        }
        
    }
}
